package com.bjwl.service.impl;

import com.bjwl.dao.SourceMapper;
import com.bjwl.pojo.Partment;
import com.bjwl.pojo.ServiceSource;
import com.bjwl.pojo.vo.BasicQueryVo;
import com.bjwl.service.SourceService;
import com.bjwl.utils.Log4jUtils;
import com.bjwl.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: dzx
 * @Date:Create：in 2020/5/11 9:32
 * @Description:
 * @Modified By：
 * @Version: 1.0
 */
@Service
public class SourceServiceImpl implements SourceService {

    @Autowired
    private SourceMapper sourceMapper;

    @Override
    public PageBean<ServiceSource> sourceList(BasicQueryVo vo) {
        PageBean<ServiceSource> pageBean = new PageBean<ServiceSource>(vo.getPageNum(),10,sourceMapper.getTotalRecord(vo));
        pageBean.setData(sourceMapper.findAllServiceSource(pageBean,vo));
        return pageBean;
    }

    @Override
    public boolean addServiceSource(ServiceSource serviceSource) {

            sourceMapper.addServiceSource(serviceSource);
            return true;

    }

    @Override
    public ServiceSource editStart(Integer id) {
        return sourceMapper.findServiceSourceById(id);
    }

    @Override
    public boolean updateServiceSource(ServiceSource serviceSource) {
        try {
            Integer state = sourceMapper.updateServiceSource(serviceSource);
        }catch (Exception e){
            return false;
        }


        return true;
    }

    @Override
    public boolean deleteServiceSource(Integer id) {
        try {
            sourceMapper.deleteServiceSource(id);
            return true;
        }catch (Exception e){
            Log4jUtils.LITERAL3.getLog().error(e.getMessage());
            return false;
        }
    }

}
